package com.company.基础.Array.oneDimensionalArray;

import java.util.Scanner;

/**
 * 从键盘中读入学生成绩，找出最高分，并输出学生成绩等级
 * 成绩>=最高分-10  等级为'A'
 * 成绩>=最高分-20  等级为‘B’
 * 成绩>=最高分-30  等级为‘C’
 * 其余            等级为‘D’
 */
public class ArrayTest5 {
    public static void main(String[] args) {
        System.out.println("请输入学生人数:");
        Scanner scanner=new Scanner(System.in);
        int perNum = scanner.nextInt();
        System.out.println("请输入"+perNum+"个成绩");
        int num=1;
        int highScore =0;
        int[] scores=new int[perNum];
        while (num<=perNum){
            scores[num-1]=scanner.nextInt();
            if (scores[num-1]>highScore){
                highScore=scores[num-1];
            }
            num++;
        }
        String level="";
        System.out.println("最高分为:"+scores);
        for (int i = 0; i < scores.length; i++) {
           if (scores[i]>=highScore-10){
                level="A";
           }else if (scores[i]>=highScore-20){
               level="B";
           }else if (scores[i]>=highScore-30){
               level="C";
           }else {
               level="D";
           }
            System.out.println("Student"+i+"score is"+scores[i]+"grade is"+level);
        }
    }
}

